﻿#include "PyFITKPhyscisPropBase.h"
#include "FITKAcousticsPhysics.h"
#include "FITKAcousticsAbsPhysicsProp.h"

Acoustics::PyFITKPhyscisPropBase::PyFITKPhyscisPropBase(const QString & name)
{
    //获取物理属性管理器
    Acoustics::FITKAcousticsPhysics* phy = Acoustics::FITKAcousticsPhysics::GetAcousticsPhysicsFromFrame();
    if (phy == nullptr) return;
    Acoustics::FITKAcousticsPhysicsPropManager* propMgr = phy->getPhysicsPropManager();
    if (propMgr == nullptr) return;
    //获取对象
    Acoustics::FITKAcousticsAbsPhysicsProp* prop = propMgr->getDataByName(name);
    if (!prop)return;
    _phyProp = prop;
}

QString Acoustics::PyFITKPhyscisPropBase::getName()
{
    if (_phyProp)
        return _phyProp->getDataObjectName();
    return QString();
}

bool Acoustics::PyFITKPhyscisPropBase::setName(const QString & name)
{
    //空字符直接返回
    if (name == "" || !_phyProp)return false;
    //获取材料管理器
    Acoustics::FITKAcousticsPhysics* phy = Acoustics::FITKAcousticsPhysics::GetAcousticsPhysicsFromFrame();
    if (phy == nullptr) return false;
    Acoustics::FITKAcousticsPhysicsPropManager* propMgr = phy->getPhysicsPropManager();
    if (propMgr == nullptr) return false;

    //获取名称-查重处理
    if (propMgr->getDataByName(name) && _phyProp->getDataObjectName() != name)return false;

    _phyProp->setDataObjectName(name);
    return true;
}
